/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.zeke.pizzastore.negocio.entities;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author taller
 */
@Entity
@Table(name = "VENTA")
@NamedQueries({
    @NamedQuery(name = "Venta.findAll", query = "SELECT v FROM Venta v"),
    @NamedQuery(name = "Venta.findByIdVenta", query = "SELECT v FROM Venta v WHERE v.idVenta = :idVenta"),
    @NamedQuery(name = "Venta.findByFecha", query = "SELECT v FROM Venta v WHERE v.fecha = :fecha"),
    @NamedQuery(name = "Venta.findByVentaTotalPesos", query = "SELECT v FROM Venta v WHERE v.ventaTotalPesos = :ventaTotalPesos")})
public class Venta implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_VENTA")
    private Long idVenta;
    @Basic(optional = false)
    @Column(name = "FECHA")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "VENTA_TOTAL_PESOS")
    private int ventaTotalPesos;
    @JoinColumn(name = "ID_ESTADO_VENTA", referencedColumnName = "ID_ESTADO_VENTA")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private EstadoVenta idEstadoVenta;
    @JoinColumn(name = "ID_DIRECCION", referencedColumnName = "ID_DIRECCION")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Direccion idDireccion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "venta", fetch = FetchType.LAZY)
    private List<VentaPizza> ventaPizzaList;

    public Venta() {
    }

    public Venta(Long idVenta) {
        this.idVenta = idVenta;
    }

    public Venta(Long idVenta, Date fecha, int ventaTotalPesos) {
        this.idVenta = idVenta;
        this.fecha = fecha;
        this.ventaTotalPesos = ventaTotalPesos;
    }

    public Long getIdVenta() {
        return idVenta;
    }

    public void setIdVenta(Long idVenta) {
        this.idVenta = idVenta;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public int getVentaTotalPesos() {
        return ventaTotalPesos;
    }

    public void setVentaTotalPesos(int ventaTotalPesos) {
        this.ventaTotalPesos = ventaTotalPesos;
    }

    public EstadoVenta getIdEstadoVenta() {
        return idEstadoVenta;
    }

    public void setIdEstadoVenta(EstadoVenta idEstadoVenta) {
        this.idEstadoVenta = idEstadoVenta;
    }

    public Direccion getIdDireccion() {
        return idDireccion;
    }

    public void setIdDireccion(Direccion idDireccion) {
        this.idDireccion = idDireccion;
    }

    public List<VentaPizza> getVentaPizzaList() {
        return ventaPizzaList;
    }

    public void setVentaPizzaList(List<VentaPizza> ventaPizzaList) {
        this.ventaPizzaList = ventaPizzaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idVenta != null ? idVenta.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Venta)) {
            return false;
        }
        Venta other = (Venta) object;
        if ((this.idVenta == null && other.idVenta != null) || (this.idVenta != null && !this.idVenta.equals(other.idVenta))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.zeke.pizzastore.negocio.entities.Venta[ idVenta=" + idVenta + " ]";
    }
    
}
